package com.lzx.lizhenxing.sys.controller;


import com.lzx.lizhenxing.common.annotation.NoLogin;
import com.lzx.lizhenxing.common.vo.CommonResult;
import com.lzx.lizhenxing.sys.param.LoginParam;
import com.lzx.lizhenxing.sys.param.RegisterParam;
import com.lzx.lizhenxing.sys.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sys/user")
public class UserController {

    @Resource
    private UserService userService;

    @NoLogin
    @PostMapping("/login")
    public CommonResult login(@RequestBody LoginParam param) {
        String token = userService.login(param);
        return CommonResult.success(token);
    }

    @NoLogin
    @PostMapping("/register")
    public CommonResult register(@RequestBody RegisterParam param) {
        userService.register(param);
        return CommonResult.success();
    }

    @PostMapping("/getUserInfo")
    public CommonResult getUserInfo() {
        return CommonResult.success(userService.getUserInfo());
    }

    @PostMapping("/logout")
    public CommonResult logout() {
        userService.logout();
        return CommonResult.success();
    }

    /**
     * 签到送积分
     * @return
     */
    @GetMapping("/sign")
    public CommonResult sign() {
        return CommonResult.success(userService.sign());
    }


    @GetMapping("/getPoint")
    public CommonResult getPoint() {
        return CommonResult.success(userService.getPoint());
    }
}
